import { Component, OnInit,Output,Input,EventEmitter } from '@angular/core';
const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };
import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';
import { Router } from '@angular/router';
import { NzModalRef, NzFormatEmitEvent, NzModalService, NzTreeComponent, NzTreeNodeOptions, NzMessageService } from 'ng-zorro-antd';
import { PagesService } from '../../services/pages.service';
import { UtilService } from '../../services/util.service';
import { RequestService } from '../../services/request.service';
declare var layui: any;
declare var layer: any;
declare var $: any;

@Component({
  selector: 'app-user',
  templateUrl: './user.component.html',
  styleUrls: ['./user.component.scss']
})
export class UserComponent implements OnInit {

  constructor(public router: Router, private http: HttpClient, public interfaceService: PagesService, public utilService: UtilService,public request:RequestService) {
    
  }

  @Output()  private  outer=new EventEmitter();
  @Input()  puc_msg:any; 


  ngOnInit() {

  }


  userStatus_list=JSON.parse(localStorage.getItem("userStatus_list"))
  popup01_url='';
  popup01_id='';
  popup01 = false;
  popup001_show(para): void {//数据验证事件，post传参
    this.interfaceService.postPage("/erp/user/getOwner/prsnlCode",para).subscribe((data: any) => {
      if (this.interfaceService.codeValidation(data)) {
      if (data.code != 200) {
        layer.msg(data.message);
      }
      this.outer.emit(data.object);   
    }
    });
  }
  popup01_show(url,id?): void {
    this.popup01_url=url
    this.popup01_id=id;
    this.popup01 = true;
    this.popup01_table();
  }
  popup01_hide(): void {
    this.popup01 = false;
    this.popup01_url='';
    this.popup01_id='';
    this.popup01_ss1='';
    this.popup01_ss2='';
    this.popup01_ss3=''; 
    this.popup01_ss4=''; 
  }

  popup01_ss1='';
  popup01_ss2='';
  popup01_ss3='';
  popup01_ss4='';
  popup01_table(){
	this.popup01_listTable(this.popup01_url+"&prsnlCode=" + this.popup01_ss1 +"&fullName=" + this.popup01_ss2 +"&mobileNum=" + this.popup01_ss3 + "&prsnlStatus=" + this.popup01_ss4);
  }

  popup01_listTable(url):void{
    setTimeout(()=>{ 
      layui.use(['table'], (obj)=>{
        var  table = layui.table
        
        table.render({
          elem: '#popup01_tblist_user'
          ,height: this.utilService.height3
          ,url: url
          ,page: true //开启分页
          ,limit:this.utilService.limit3
			    ,limits:this.utilService.limits
          ,title: '数据表'
          ,cellMinWidth: 100
          ,cols: [[
            {title: '序号', type: 'numbers',fixed: 'left'},
          {field: 'userId', title: 'userId',width:100,hide:'true'},
          {field: 'ownerId', title: 'ownerId',width:100,hide:'true'},
          {field: 'prsnlCode', title: '人员代码',width:120}
          ,{field: 'fullName', title: '用户名',width:120} 
          ,{field: 'officeNum', title: '办公电话号码',width:150} 
          ,{field: 'mobileNum', title: '移动电话号码',width:150} 
            ]]
          ,request: {
            pageName: 'page' //页码的参数名称，默认：page
            ,limitName: 'size' //每页数据量的参数名，默认：limit
          }
          ,parseData: function(res){ //res 即为原始返回的数据
            return {
              "code": res.code, //解析接口状态
              "msg": res.message, //解析提示文本
              "count": res.object.total, //解析数据长度
              "data": res.object.list //解析数据列表
            }
          }
          ,response: {
            statusCode: 200 //规定成功的状态码，默认：0
            ,dataName: 'data' //规定数据列表的字段名称，默认：data
          } 
        });
        table.on('rowDouble(popup01_tblist_user)', (obj)=>{
          this.popup01_hide();
          this.outer.emit(obj.data)       
         });
        
      });
      
    },50);
  
  }

}
